package com.handc.springcloud.controller;


import com.handc.springcloud.pojo.Student;
import com.handc.springcloud.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping("/stu/get/{id}")
    public Student getById(@PathVariable("id") Long id){
        return studentService.queryById(id);
    }

    @PostMapping("/stu/add")
    public boolean addStudent(Student student){
        return studentService.addStudent(student);
    }

    @GetMapping("/stu/list")
    public List<Student> list(){
        return studentService.queryAll();
    }
}
